﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <form name="f1">
        <input type="text" name="t1" />
        <input type="button" value="Click me" onclick="f()" id="btn1" />
        <div id="id1"></div>
    </form>

    <script type="text/javascript">
        function f() {
            window.setTimeout("populate()", 2000);
        }

        function populate() {
            document.f1.t1.value = "popualate";
            document.getElementById("id1").innerHTML = "<div id='id2'>id 2</div>";
        }

    </script>
</body>
</html>